One GUI that fill attributes in multiples modules.

Hi.
I'm having a problem, i created a GUI that you can choose which modules you want to open in your DOORS directory, and then a button that call another GUI with a checklist. So far its okay.

The problem is that when i click in the button that calls the other GUI, and answer the same, only one of the modules have its attributes filled.

I needed a help, because i don't know exactly where solve my problem, if is in the GUI that calls and open the modules in exclusive edit, or in the GUI that answer the checklist and fills the attributes.

bold This is the code for the Checklist
 

/*===========================================================================================
 Date: 09/07/2012
 Bruna Aquino
==========================================================================================*/
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                        //////////////  Variables //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
 
Object obj = current
 
int iQCSYS, iQCHF
string currentQCSYS, currentQCHF
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                                  /////////////// Interface Items ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - TEST")
 
DB helpBox = create("Help")
DB detailsCS = create("Detailed Questions")
DB detailsCH = create("Detailed Questions")
 
DBE newReportButton, nextButton, prevButton
DBE tagField, statusField, authorField, propCheckerField 
DBE selectChoiceQCSYS, selectChoiceQCHF
DBE richTextReq, richTextApp, textMultiLine, selectHelp
 
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                     ///////////////Loop through open modules ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Module mod
string NameMod
Skip skpMods = createSting()  // KEY: 'string' NameMod(base); DATA: 'Module' handle
for mod in database do
{  NameMod = name(mod)   // the 'fullName(mod)' would include the path info
   put(skpMods, NameMod, mod)  // Put the name as Key.
}  // end for open modules in the Database
 // loop through Key-sorted Skip, which is Alpha since the key is the 'name' -
 
for mod in skpMods do             // Skips loop through the DATA -
{  NameMod = (string key skpMods) // Retrieve the KEY (name) associated with this DATA mod
   if (!isEdit(mod)     continue
   ProcessOpenEditModule(mod)  
}  // end for open modules in the Skip
delete(skpMods)
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                             ///////////////    Answer Types ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
 
AttrType answerType = find(current Module, "Answer")
 
if (null answerType) answerType = create ("Answer", options, errMess)
 
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                                        ///////////////  Functions  //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){ 
  AttrDef ad = find(current Module, s) 
  if (null ad) // print "Attr Def  '" s "' does not exist.\n"
  else delete(ad) 
} 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
 
void deleteAttrType(string s){
  string err = "" 
  AttrType at = find(current Module, s)   
  if (null at) // print "Attr Type  '" s "' does not exist.\n"
  else delete(at, err)  
} 
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
// Status field will always reflect the actual answers for all questions
void setStatus(){    
    /*
           Important: The following conditions shall be the same as used in dxl of 'Validation Status' column to show current status.
        */
        m = current Module
        Object o
        bool ValInd, NotEvalInd, NotValInd
        ValInd = false
        NotEvalInd = false
        NotValInd = false
        for o in m do {
        if (null o."Object Heading" "") {
        if (((o."Validation Q1SYS" ""=="YES" &&   o."Validation Q2SYS" ""=="YES" && o."Validation Q2HF" ""=="YES" && o."Validation Q1HF" ""=="YES")||(o."Validation Q1SYS" ""=="N/A" && o."Validation Q1HF" ""=="N/A" && o."Validation Q2SYS" ""=="YES" && o."Validation Q2HF" ""=="YES")||(o."Validation Q1SYS" ""=="YES" &&     o."Validation Q1HF" ""=="YES" && o."Validation Q2SYS" ""=="N/A" && o."Validation Q2HF" ""=="N/A")) && (m."Validation QCSYS" ""=="YES" && m."Validation QCHF" ""=="YES")) {
                          ValInd = true
                          }  
        else {       
        if ((o."Validation Q1SYS" ""=="Not Evaluated" && o."Validation Q1HF" ""=="Not Evaluated" && o."Validation Q2SYS" ""=="Not Evaluated" && o."Validation Q2HF" ""=="Not Evaluated") && ((m."Validation QCSYS" ""=="Not Evaluated" && m."Validation QCHF" ""=="Not Evaluated")||(m."Validation QCSYS" ""=="YES" && m."Validation QCHF" ""=="YES"))) {
                                          NotEvalInd = true
                                         }else NotValInd = true 
                                }
        }
        }
                if (NotValInd) {
                        m."Completeness Validation Status" = "Not Valid"
                        } else if (NotEvalInd){
                        m."Completeness Validation Status" =  "Not Validated"
                        } else m."Completeness Validation Status" = "Valid" ""
}
                        
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/          
// Return the last author of the current object
string lastObjectTextModifier(){
        History h 
        string lastAuthor = ""
    for h in current Object do {
            HistoryType ht = h.type 
                if (ht == modifyObject && h.attrName == "Object Text") lastAuthor = h.author 
        }
        return lastAuthor
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
// Test if 'Author' is the same as 'Checker' (actual user).
bool isAuthor(){
        User u = find() // returns current user login.
        string userLogin = u.name
        if(exists attribute "Author"){     // Avoid errors
                if(userLogin == obj."Author" "") return true                
        }
        return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
void updateVariables() {
        m = current Module
        string currentQCSYS = m."Validation QCSYS" ""
        string currentQCHF = m."Validation QCHF" ""
                        
        for iQCSYS in 0:3 by 1 do {
                if (currentQCSYS == answerType.strings[iQCSYS]) { break }
                iQCSYS++
        }
        for iQCHF in 0:3 by 1 do {
                if (currentQCHF == answerType.strings[iQCHF]) { break }
                iQCHF++
        }
                        
        set(selectChoiceQCSYS,iQCSYS)
        set(selectChoiceQCHF,iQCHF)
        set(textMultiLine, m."Completeness Validation Comments" "")
        setStatus()             
        refresh current Module
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
bool notExistAttribute(string aName){        
        AttrDef ad = find(current Module, aName) 
        if (null ad) return true
        else return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
 
// Save all validation questions and Validation Comments
void saveObjects(){
    User u = find() // returns current user login.
    string userLogin = u.name
        string aux = ""
        int i
        bool wasModified = false
        m = current Module
                
                
                
                
    if (get(selectChoiceQCSYS) =="NO" || get(selectChoiceQCHF)=="NO" ) {
                        if (get(textMultiLine) == "") {
                                warningBox("Add comments that describe why the requirement is not valid or the data entered will not be saved.\nThis will help author to correct the requirement.")
                                return
                        }
                }
        
           if(canModify(m)){
                    
                        aux = get(selectChoiceQCSYS)
                        if(m."Validation QCSYS" "" != aux) {
                                m."Validation QCSYS" = aux
                                wasModified = true
                                }
                        aux = get(selectChoiceQCHF)
                        if (userLogin != null) { 
                        if(!matches("JAANDRAD", userLogin)) { //vefiry if the user is from the group
                                if (get(selectChoiceQCHF)=="YES" ) {
                                if (get(textMultiLine) == "") {
                                    warningBox("You cannot change the Question1HF to YES because you do not pertain to G-DOORS-EMB550-HF group.")
                                    return
                            }
                    }
            
                        else{
                        aux = get(selectChoiceQCHF)
                        if(m."Validation QCHF" "" != aux) {
                                m."Validation QCHF" = aux
                                wasModified = true
                                }
                }
            }
                }    
                        
                aux = get(textMultiLine)
                        if(m."Completeness Validation Comments" "" != aux) {
                                m."Completeness Validation Comments" = get(textMultiLine)
                                wasModified = true
                        }
        }                    
                
        else infoBox "Cannot modify current object."
}
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
void saveReport(DB calledFrom){              
        saveObjects() // Saves all validation questions and Validation Comments.        
        save(current Module)
        refresh (current Module)        
}
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
void closeBox(DB calledFrom){        
        if(unsaved(current Module)){                 
                string buttons[] = {"Yes", "No"} 
                int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning) 
                if(buttons[answer] == "Yes") {
                        saveObjects() // Saves all validation questions and Validation Comments.        
                        save(current Module)
                        refresh (current Module)        
                }    
        }
        hide calledFrom
}
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
bool notExistAttribute(string attrName){
        AttrDef ad = find(current Module, attrName) 
        if (null ad) return true
        else {
                // print "Attribute  '" attrName "' alredy exists. Could not create.\n"
                return false
        }
}
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/  
// Some checks to init GUI.
bool canInit(){
        
        // Check if module has requirements.
        if(null obj) {
                infoBox "Module without requirements to validate."
                return  false
        }
        
        // Check if module is in exclusive edit or not.
        if(!canModify(current Object)){
                infoBox "Open module as Shareable or Exclusive Edit."
                return  false
        }
        return true
}
 
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
                        //////////////////  Main Program  //////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
 
// Start to buid GUI
if(canInit()){ 
        m = current Module
 
        saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
        close(verEvidenceBox, true, closeBox)
 
        
        // Questions 
        selectChoiceQCSYS = choice(verEvidenceBox, "Q1SYS ?", options, 1, 13,false)
        selectChoiceQCHF = choice(verEvidenceBox, "Q1HF ?", options, 1, 13,false)
 
                                        
        statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
        
        textMultiLine = text(verEvidenceBox, "Completeness Validation Comments", m."Completeness Validation Comments" "" ,30, 60, false )
        
        updateVariables()       
        show verEvidenceBox
}

Bruwbruw - Wed Jul 18 12:28:01 EDT 2012

Re: One GUI that fill attributes in multiples modules.
Bruwbruw - Wed Jul 18 12:31:35 EDT 2012

The code the from the GUI that you choose the modules and open then in exclusive edit...

const int TREE_VIEW_WIDTH = 300
const int TREE_VIEW_HEIGHT = 14
 
const int LIST_VIEW_WIDTH = 400
const int LIST_VIEW_HEIGHT = 14
 
const string MODULES_FRAME_LABEL =  "Select items" 
const int MODULES_FRAME_WIDTH = 540
const int MODULES_FRAME_HEIGHT = 12
 
 
/*    -------------------------------- **** --------------------------------
        Variables
        -------------------------------- **** -------------------------------- */
bool ret
 
DB selectModulesDB
DBE hierarchyTreeView
DBE selectedListView
DBE treeViewLabel
DBE dateUsedToggle
DBE modulesListFrame
DBE InitComplVal
DBE CreateBase
 
/*      -------------------------------- **** --------------------------------
Open select modules in exclusive edit
        -------------------------------- **** -------------------------------- */
 
void openModules() {
        Item selItem
        int selItemToken
        Module selMod
        
        for (selItemToken=0; selItemToken<noElems(selectedListView); selItemToken++) {
                raise(selectModulesDB)
                selItem = item(get(selectedListView, selItemToken))
 
                if (null selItem) {
                        // If not found, then not found
                        set(selectedListView, selItemToken)
                } else {
                        if (type(selItem)!="Formal") {
                                // If not a formal module, it's not applicable
                                set(selectedListView, selItemToken)
                        } else {
                                selMod = edit(rootName_(selItem), false, false)
                                if (null selMod) {
                                        // If not found, then not found
                                        set(selectedListView, selItemToken)
                                }  
                        } 
                } 
        }
}
 
 
/*      -------------------------------- **** --------------------------------
                Given an index, returns object
        -------------------------------- **** -------------------------------- */
void findObj(int objIndex, Object &foundObj, Module &selMod) {
        Object objPointer
        int intCounter
        
        intCounter = 1
        for objPointer in selMod do {
                if (intCounter == objIndex) {
                        foundObj = objPointer
                }
                intCounter++
        }
}
/*      -------------------------------- **** --------------------------------
                Returns true if item exists in given column of list view 
        -------------------------------- **** -------------------------------- */
bool existsInListView(DBE listViewToSearch, int columnToSearch, string valueSearched) {
        int noOfElemsListView
        int itemCounter
        
        string errMsg
        noError()
        
        noOfElemsListView = noElems(listViewToSearch)
        
        // if list view is empty, returns false
        if (noOfElemsListView == 0) {
                
                errMsg = lastError()
                if(!null errMsg) {
                                print "Error in existsInListView() \n" errMsg "\n"
                        return false
                } else {
                        return false
                }
        }
        
        // if list view is not empty, search for string
        for (itemCounter=0; itemCounter<noOfElemsListView; itemCounter++) {
                
                if (valueSearched == getColumnValue(listViewToSearch, itemCounter, columnToSearch)) {
                        
                        errMsg = lastError()
                        if(!null errMsg) {
                                        print "Error in existsInListView() \n" errMsg "\n"
                                return false
                        } else {
                                return true
                        }            
                }
                
        }
        
        errMsg = lastError()
        if(!null errMsg) {
                print "Error in existsInListView() \n" errMsg "\n"
                return false
        }
        return false
}
 
/*      -------------------------------- **** --------------------------------
                Adds an item to the list view
        -------------------------------- **** -------------------------------- */
bool addItemListView(DBE toAddlistView, string pathStr, string typeStr) {
        string errMsg
        noError()
        
        // Only adds item if it does not exists in List view
        if (!existsInListView(toAddlistView, 0, pathStr)) {
                                                
                if (typeStr == "Project") {
                        insert(toAddlistView, 0, pathStr, iconProject)
                        set(toAddlistView, 0, 1, "Project")
                        set(toAddlistView, 0, 2, "Not run")
                        set(toAddlistView, 0, 3, "")
                } else {
                        if (typeStr == "Folder") {
                                insert(toAddlistView, 0, pathStr, iconFolder)
                                set(toAddlistView, 0, 1, "Folder")
                                set(toAddlistView, 0, 2, "Not run")
                                set(toAddlistView, 0, 3, "")
                        } else {
                                if (typeStr == "Formal") {
                                        insert(toAddlistView, 0, pathStr, iconFormal)
                                        set(toAddlistView, 0, 1, "Formal")
                                        set(toAddlistView, 0, 2, "Not run")
                                        set(toAddlistView, 0, 3, "")
                                } else {
                                        if (typeStr == "Link") {
                                                insert(toAddlistView, 0, pathStr, iconLink)
                                                set(toAddlistView, 0, 1, "Link")
                                                set(toAddlistView, 0, 2, "Not run")
                                                set(toAddlistView, 0, 3, "")
                                        }
                                }
                        }
                }
                
        }
        
        errMsg = lastError()
        if(!null errMsg) {
                print "Error in addItemListView() \n" errMsg "\n"
                return false
        }
        return true
 
}
 
/*      -------------------------------- **** --------------------------------
                Callback called when a drag-and-drop action is finished 
        -------------------------------- **** -------------------------------- */
void dropSelectedItem(DropEvent dropItem) {
        int optionsSelected
        Item selectedItem
        Item withinItem
        string selectedItemTypeStr
        string withinItemTypeStr
        bool errWhenAdding
 
        string errMsg
        noError()
        
        noErrWhenAdding = true
 
        // Get item associated with selected path
        selectedItem = item("/" dropItem.sourcePath)
        selectedItemTypeStr = type(selectedItem)
        
        // Add to list according to option selected and item selected
        if ((dropItem.sourceIsTreeView == true) && (dropItem.targetIsListView == true)) {
                
                // If folder or project, add all formal modules within to select list
                for withinItem in folder(selectedItem) do {
                        withinItemTypeStr = type(withinItem)
                        
                        if (withinItemTypeStr=="Formal") {
                                noErrWhenAdding = noErrWhenAdding && (addItemListView(selectedListView , rootName_(withinItem), withinItemTypeStr))
                        }
 
                } // end for
                
                // If formal, add formal to select list
                if (selectedItemTypeStr == "Formal") {
                        noErrWhenAdding = noErrWhenAdding && addItemListView(selectedListView , rootName_(selectedItem), selectedItemTypeStr)
                } 
                
        } // end if
        
        // Remove from list
        if ((dropItem.sourceIsListView == true) && (dropItem.targetIsTreeView == true)) {
                delete(selectedListView, dropItem.sourceIndex) 
        }
        
        errMsg = lastError()
        if ((!null errMsg) || (!noErrWhenAdding)) {
                        print "Error in dropSelectedItem() \n" errMsg "\n"
                return
        }
        return
}
 
 
/*      -------------------------------- **** --------------------------------
    Call the checklist
        -------------------------------- **** -------------------------------- */
void InitComplVal(DB calledFrom) {   
openModules()
eval_ "#include <//Sjkfs05/Eng_Av_Executiva/14_Sist_Eletro_Eletronicos/Docs_Processos_Sw/Sys&SW Process/System Process/06_DOORS DXL/DXL in Use/Synoptics Completeness Validation Checklist - TEST.dxl>"
        }
        
/*      -------------------------------- **** --------------------------------
    Call DOORS function: New BaselineSet
        -------------------------------- **** -------------------------------- */       
void CreateBase(DB calledFrom) {             
string create(Folder f, string name, string desc, BaselineSetDefinition &bsd)
    }        
        
 
/*      -------------------------------- **** --------------------------------
                Initialize globals
        -------------------------------- **** -------------------------------- */
bool initGlobals(){
        string listViewItems[]
        
        string errMsg
        noError()
 
        // Dialog box
        selectModulesDB = create("Completeness Validation Rev-", styleFixed)
        
        // Dialog box elements
        modulesListFrame = frame(selectModulesDB, MODULES_FRAME_LABEL, MODULES_FRAME_WIDTH, MODULES_FRAME_HEIGHT)
        hierarchyTreeView = treeView(selectModulesDB, dropSelectedItem, treeViewOptionSorted, TREE_VIEW_WIDTH, TREE_VIEW_HEIGHT)
        selectedListView = listView(selectModulesDB, dropSelectedItem, listViewOptionMultiselect, LIST_VIEW_WIDTH, LIST_VIEW_HEIGHT, listViewItems)
    InitCompButton = apply(selectModulesDB, "Init Completeness Validation", InitComplVal)
        CBaseButton = apply(selectModulesDB, "Create Baselines", CreateBase)
        
        errMsg = lastError()
        
        if(!null errMsg) {
                        print "Error in initGlobals() \n" errMsg "\n"
                return false
        }
        return true
}
 
/*      -------------------------------- **** --------------------------------
                Arrange elements in dialog box, format elements
        -------------------------------- **** -------------------------------- */
bool formatDialogBox(){
        string errMsg
        noError()
        
        // Placement
        // Modules frame
        modulesListFrame->"top"->"form"
        modulesListFrame->"bottom"->"unattached"
        modulesListFrame->"left"->"form"
        modulesListFrame->"right"->"form"
        
        // Tree view
        hierarchyTreeView->"top"->"inside"->modulesListFrame
        hierarchyTreeView->"bottom"->"unattached"
        hierarchyTreeView->"left"->"inside"->modulesListFrame
        hierarchyTreeView->"right"->"unattached"
        
        // List vew
        selectedListView->"top"->"inside"->modulesListFrame
        selectedListView->"bottom"->"inside"->modulesListFrame
        selectedListView->"left"->"flush"->hierarchyTreeView
        selectedListView->"right"->"inside"->modulesListFrame
        
        // Realize
        realize(selectModulesDB)
        hide modulesListFrame
        
        // Dialog box size
        setSize(selectModulesDB, 750, 370)
        
        // Behavior when resizing
        // Horizontal
        setExtraHeightShare(modulesListFrame, 1.0)
        setExtraHeightShare(hierarchyTreeView, 1.0)
        setExtraHeightShare(selectedListView, 1.0)
        
        // Vertical
        setExtraWidthShare(modulesListFrame, 0.5)
        setExtraWidthShare(hierarchyTreeView, 0.5)
        setExtraWidthShare(selectedListView, 0.5)
        
        errMsg = lastError()
        
        if(!null errMsg) {
                        print "Error in formatDialogBox() \n" errMsg "\n"
                return false
        }
        return true
}
 
/*      -------------------------------- **** --------------------------------
                Expand tree view item 
        -------------------------------- **** -------------------------------- */
bool expandTreeViewItem(DBE treeViewCaller, string treeViewBranch){
        string errMsg
        noError()
 
        errMsg = lastError()
                
        if(!null errMsg) {
                        print "Error in expandTreeViewItem() \n" errMsg "\n"
                return false 
        }
        
        return true
}
 
/*      -------------------------------- **** --------------------------------
                Tree view item is selected
        -------------------------------- **** -------------------------------- */
void itemSelectedTreeView(DBE treeViewCaller){
        string selectedPathStr
        string selectedItemTypeStr
        string indexItemNameStr
        string indexItemTypeStr
        Item selectedItem
        Item indexItem
        
        string errMsg
        noError()
        
        // Get selected path
        selectedPathStr = get(treeViewCaller)
                
        // Get item associated with selected path
        selectedItem = item("/" selectedPathStr)
        
        if (!null selectedItem) {
                // Identify type of the selected item 
                selectedItemTypeStr = type(selectedItem)
 
                // If selected item is folder or project, add sub-items 
                if ((selectedItemTypeStr == "Folder") || (selectedItemTypeStr == "Project")) {
                        // Add sub-folders, sub-projects and modules
                        for indexItem in folder(selectedItem) do {
                                indexItemNameStr = name(indexItem)
                                indexItemTypeStr = type(indexItem)
                                
                                // Check if full path already exists
                                if (!exists(hierarchyTreeView, "/" selectedPathStr "/" indexItemNameStr)) {
                                        if (indexItemTypeStr == "Project") {
                                                insert(hierarchyTreeView, "/" selectedPathStr "/" indexItemNameStr, iconProject, iconProjectOpen)
                                        } else {
                                                if (indexItemTypeStr == "Folder") {
                                                        insert(hierarchyTreeView, "/" selectedPathStr "/" indexItemNameStr, iconFolder, iconFolderOpen)
                                                } else {
                                                        if (indexItemTypeStr == "Formal") {
                                                                insert(hierarchyTreeView, "/" selectedPathStr "/" indexItemNameStr, iconFormal, iconFormal)
                                                        }                                           
                                                }
                                        }
                                }
                        }
                }   
        }
        
        errMsg = lastError()
                
        if(!null errMsg) {
                        print "Error in itemSelectedTreeView() \n" errMsg "\n"
                return 
        }
        
        return
}
 
/*      -------------------------------- **** --------------------------------
                Populates tree view with hierarchy from root
        -------------------------------- **** -------------------------------- */
bool populateTreeView(){
        Folder rootFolder
        Item refItem
        string itemNameStr
 
        string errMsg
        noError()
        
        rootFolder = folder "/"
        for refItem in rootFolder do {
                itemNameStr = fullName(refItem)
                                
                if (type(refItem)=="Project") then {
                        insert(hierarchyTreeView, itemNameStr, iconProject, iconProjectOpen)    
                } else {
                        if (type(refItem)=="Folder") then {
                                insert(hierarchyTreeView, itemNameStr, iconFolder, iconFolderOpen)
                        }
                }
        }
        
        // Free memory
        delete rootFolder
        delete refItem
        
        // Set callbacks
        set(hierarchyTreeView, expandTreeViewItem)
        set(hierarchyTreeView, itemSelectedTreeView, itemSelectedTreeView)
        
        errMsg = lastError()
        
        if(!null errMsg) {
                        print "Error in populateTreeView() \n" errMsg "\n"
                return false 
        }
        return true     
}
 
/*      -------------------------------- **** --------------------------------
                Formats list view
        -------------------------------- **** -------------------------------- */
bool formatListView(){
        string errMsg
        noError()
        
        insertColumn(selectedListView, 0, "Modules going through Compleness Validation", 529, iconNone)
        
        if(!null errMsg) {
                        print "Error in formatListView() \n" errMsg "\n"
                return false 
        }
        return true
}
 
/*      -------------------------------- **** --------------------------------
                Finalize application: close modules, free memory
        -------------------------------- **** -------------------------------- */
bool finalize(){
        string errMsg
        noError()
 
        if (showing(selectModulesDB)) {
                hide selectModulesDB
                empty selectedListView
                empty hierarchyTreeView
        }
        
        destroy selectModulesDB
                        
        hierarchyTreeView = null
        selectedListView = null
        selectModulesDB = null  
        
        errMsg = lastError()
        
        if(!null errMsg) {
                        print "Error in finalize() \n" errMsg "\n"
                return false 
        }
        return true
}
 
/*      -------------------------------- **** --------------------------------
        Main
        -------------------------------- **** -------------------------------- */
ret = initGlobals()
if (!ret) then {
        errorBox("Error initializing application. Stopping now.")
        finalize()
        halt
}
 
ret = formatDialogBox()
if (!ret) then {
        errorBox("Error creating user dialog box. Stopping now.")
        finalize()
        halt
}
 
ret = populateTreeView()
if (!ret) then {
        errorBox("Error populating user dialog box. Stopping now.")
        finalize()
        halt
}
 
ret = formatListView()
if (!ret) then {
        errorBox("Error formatting user dialog box. Stopping now.")
        finalize()
        halt
}
 
block selectModulesDB
 
ret = finalize()
if (!ret) then {
        errorBox("Error finalizing application.")
        halt
} else {
        infoBox("Application finalized. Ok!")
        halt
}